home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / Maestro / Scripts / installDemos < prev    next >
Encoding:
Text File  |  1996-01-15  |  4.8 KB  |  136 lines

  1. #!/bin/csh -f
  2. # Installation script for MAEstro demos.
  3. # Copyright (C) 1994 by George D. Drapeau
  4. #
  5.  
  6. set OsRelease = `uname -r`                    # What release of the operating system is this?
  7. switch ($OsRelease)
  8.   case "4.*":                            # SunOS 4.X
  9.     set RootDir = /cdrom/MAEstro                # Set top-level directory from which to retrieve MAEstro demos
  10.   breaksw
  11.   case "5.*":                            # SunOS 5.X
  12.     set RootDir = /cdrom/unnamed_cdrom/MAEstro        # Set top-level directory from which to retrieve MAEstro demos
  13.   breaksw
  14.   default:                            # Probably not any SunOS
  15.     set RootDir = /cdrom/MAEstro                # Set top-level directory from which to retrieve MAEstro demos
  16.   breaksw
  17. endsw    
  18.  
  19.  
  20. set DestDir = "/usr/local/MAEstro"                # Set up a default directory for the MAEstro demos
  21.  
  22. set MAEstroDemoDir = "$RootDir/Demos"                # Determine where to find the correct MAEstro applications
  23. set MAEstroDemoString = "/cdrom/MAEstro/Demos"            # Set up string to use when renaming paths for demo documents
  24.  
  25. if (!(-e $MAEstroDemoDir)) then
  26.         echo "Cannot find the directory $RootDir.  Please make sure"
  27.     echo "that you have mounted the CD-ROM as /cdrom, then try"
  28.     echo "this installation script again."
  29.         exit (-1)
  30. endif
  31.  
  32. set DiskSpaceNeeded = `du -s $MAEstroDemoDir | awk '{print $1}'`# Determine disk space needed to install the MAEstro demos
  33.  
  34. echo ""
  35. echo "The default installation directory is "
  36. echo "    $DestDir"
  37. echo ""
  38. echo "MAEstro demos require $DiskSpaceNeeded KB of disk space."
  39. echo ""
  40. echo "Would you like to install MAEstro demos into "
  41. echo -n "'$DestDir'? [y/n] "
  42. set DestDir_ok = $<                        # Ask the installer if the default directory is okay.
  43.  
  44.  
  45. CustomInstallDirectory:                        # Here begins code to install demos in a custom directory
  46.  
  47. if ($DestDir_ok != y) then                    # The default directory is not okay, prompt for a new place
  48.     echo ""
  49.         echo "Where would you like to install MAEstro demos? "
  50.     echo "(type 'q' to quit the installation process now.)"
  51.     echo -n "--> "
  52.         set DestDir = $<
  53. endif
  54.  
  55. if ($DestDir == "q") then                    # Did the installer choose to exit without installing the demos?
  56.   echo "MAEstro demos were not installed."
  57.   exit (-1)                            # Yes, honor that choice and quit right now
  58. endif
  59.  
  60. if (!(-e $DestDir)) then                    # Does the specified directory exist?
  61.   echo ""
  62.   echo "The directory '$DestDir' does not exist."
  63.   echo -n "Would you like to create it? [y/n] "            # No, shall this program create such a directory?
  64.   set create = $<
  65.   if ($create == y) then                    # Yes, try to create the directory specified by the installer
  66.           echo  -n "Creating installation directory..."
  67.       mkdir $DestDir >& /dev/null                # Create the directory and set appropriate permissions
  68.       if ($status != 0) then
  69.         echo ""
  70.         echo "Could not create the directory $DestDir."
  71.         echo "Please try another directory name."
  72.         echo ""
  73.         goto CustomInstallDirectory
  74.       endif
  75.       chmod 0755 $DestDir
  76.           echo "Done."
  77.   else
  78.           echo "Please try again:"
  79.       echo ""
  80.       goto CustomInstallDirectory
  81.   endif
  82. else
  83.   echo ""
  84. endif
  85.  
  86. #
  87. # Avoid problems with long df entries...
  88. #
  89. set DF_LONG = `df $DestDir | tail -1 | awk '{print $4}' | egrep % | wc -c`
  90. if ( $DF_LONG == "0" ) then 
  91.         set FreeDiskSpace = `df $DestDir | tail -1 | awk '{print $4}'`
  92. else
  93.         set FreeDiskSpace = `df $DestDir | tail -1 | awk '{print $3}'`
  94. endif
  95.  
  96. if ($FreeDiskSpace < $DiskSpaceNeeded) then            # Is there enough space to hold the MAEstro demos?
  97.   echo "Sorry, MAEstro demos require $DiskSpaceNeeded KB of free disk space"    # No, inform the installer
  98.   echo "but there are only $FreeDiskSpace KB free in '$DestDir'."
  99.   echo "Please free up disk space or install MAEstro demos"
  100.   echo "in a different directory, then run this installation script again."
  101.   exit (-1)                            # Exit this script without doing any installation
  102. endif
  103.  
  104.  
  105. echo ""
  106. echo -n "Installing MAEstro demo content material into '$DestDir'..."
  107.  
  108. cp -r $MAEstroDemoDir/* $DestDir                # Copy the MAEstro demos into the desired directory
  109.  
  110. echo "Done."
  111.  
  112. cd $DestDir                            # Go to the installed Demos directory to repair files
  113.  
  114. foreach i (Demo*)                        # Look at each demo directory, doing the following:
  115.   pushd $DestDir/$i >& /dev/null                # Go to that demo directory
  116.   echo -n "Installing Demo '$i'..." 
  117.   foreach fileName (*)                        # Look at each file in the directory
  118.     grep $MAEstroDemoString $fileName >& /dev/null
  119.     set result = $status
  120.     if ($result == 0) then                    # Is there something to replace?
  121.       cat $fileName | \
  122.      sed "s@$MAEstroDemoString@$DestDir@" > $fileName.New    # Yes, set the path of the document to that of the...
  123.       rm -f $fileName                        # ...directory where the demo is installed.
  124.       mv $fileName.New $fileName                # Delete old file and replace it with new file
  125.     endif
  126.   end
  127.   echo "Done."
  128.   popd >& /dev/null
  129. end
  130.  
  131.  
  132. echo ""
  133. echo 'Installation was successful.  Enjoy\!'
  134.  
  135. exit (0)                            # Installation was successful; get outtahere.
  136.